package modules

import "github.com/templui/templui/internal/shared"
import "github.com/templui/templui/internal/ctxkeys"

templ Sidebar() {
	<aside class="h-full">
		<div class="flex h-full flex-col overflow-auto px-2 pb-12">
			<nav class="space-y-6">
				for _, section := range shared.Sections {
					<div class="relative flex w-full flex-col">
						<div class="flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-muted-foreground">
							{ section.Title }
						</div>
						<div class="w-full text-sm">
							<ul class="flex w-full flex-col gap-0.5">
								for _, link := range section.Links {
									<li class="relative">
										<a
											href={ templ.SafeURL(link.Href) }
											if link.Href != "/llms.txt" {
												hx-get={ string(templ.SafeURL(link.Href)) }
												hx-target="#main-content"
												hx-push-url="true"
												hx-swap="innerHTML"
											}
											if link.Href == ctx.Value(ctxkeys.URLPathValue) {
												class="inline-flex items-center gap-2 rounded-md p-2 text-[0.8rem] bg-accent hover:bg-accent"
											} else {
												class="inline-flex items-center gap-2 rounded-md p-2 text-[0.8rem] hover:bg-accent hover:text-accent-foreground"
											}
										>
											{ link.Text }
										</a>
									</li>
								}
							</ul>
						</div>
					</div>
				}
			</nav>
		</div>
	</aside>
}
